
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="${pageContext.request.contextPath}/page/css/common.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath}/page/css/style.css" rel="stylesheet" type="text/css" />



  <script type="text/javascript" src="${pageContext.request.contextPath}/page/js/jquery-1.8.3.js"></script>
  <script type="text/javascript">


      function ajax() {
          var xhr=new XMLHttpRequest();
          var name=document.getElementById("name").value;
          console.log(name);
          xhr.open("post","${pageContext.request.contextPath}/user/selectByName.do");
          //设值post请求，请求头
         xhr.setRequestHeader("content-type","application/x-www-form-urlencoded");

          xhr.send("user_name="+name);


          xhr.onreadystatechange=function(){
              if(xhr.readyState==4&&xhr.status==200){
                  var result=xhr.responseText;
                  if(result=="0"){
                      document.getElementById("pm").innerText="可以使用";
                  }else {
                      document.getElementById("pm").innerText="该名称已被注册";
                  }
              }
          }
      }

  </script>
</head>

<body>
<div class="wrap">
  <!-- main begin-->
  <form action="${pageContext.request.contextPath}/add">
      <div class="zclf login logns">
        <h1  class="blue">用户注册</h1>
          <dl>
            <dd>
              <label> <small>*</small>用户名</label>
              <input type="text" class="inputh lf" name="user_name" id="name" onblur="ajax()"/><span id="pm"></span>
             <div class="lf red laba">用户名要求不低于6个字符</div>
            </dd>
            <dd>
              <label> <small>*</small>密码</label>
              <input type="text" class="inputh lf" name="user_password" />
              <div class="lf red laba">密码要求不低于6个字符</div>
            </dd>
            <dd>
              <label> <small>*</small>身份证号</label>
              <input type="text" class="inputh lf" name="user_card_no" />
              <div class="lf red laba">身份证号必填</div>
            </dd>
            <dd>
              <label> <small>*</small>电话</label>
              <input type="text" class="inputh lf" name="user_tel" />
              <div class="lf red laba">电话号码必填</div>
            </dd>
            <dd>
              <label> <small>*</small>住址</label>
              <input type="text" class="inputh lf" name="user_address" />
            </dd>
            <dd>
              <label> <small>*</small>邮政编码</label>
              <input type="text" class="inputh lf" name="user_post_number" />
            </dd>

            <dd class="hegas">
              <label>&nbsp;</label>
               <input name=""  type="checkbox" id="rem_u"   />
              <label for="rem_u" class="labels">我同意<span class="blues">《服务条款》</span></label>
            </dd>
            <dd class="hegas">
              <label>&nbsp;</label>
              <input  type="submit" value="立即注册" class="spbg buttombg buttombgs f14 lf" />
            </dd>
          </dl>
    </div>
<!-- main end-->
<!-- footer begin-->
  </form>
</div>

 <!--footer end-->
 
</div>
</body>
</html>
